package fi.uba.tecnicas.diseno.tp2.ui;

import java.math.BigDecimal;
import org.jdesktop.beansbinding.Converter;

public class PriceConverter extends Converter<BigDecimal, String> {

    public String convertForward(BigDecimal arg) {
        return String.valueOf(arg);
    }

    public BigDecimal convertReverse(String arg) {
        BigDecimal value;
        try {
            value = (arg == null) ? BigDecimal.ZERO : new BigDecimal(arg);
        } catch (NumberFormatException ex) {
            value = BigDecimal.ZERO;
        }
        return value;
    }

}
